package whr.modules.ask.controller;

import java.util.Arrays;
import java.util.Map;

import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import whr.modules.ask.entity.SalaryEntity;
import whr.modules.ask.service.SalaryService;
import whr.common.utils.PageUtils;
import whr.common.utils.R;



/**
 * 
 *
 * @author liuli
 * @email 
 * @date 2024-11-01 10:54:10
 */
@RestController
@RequestMapping("ask/salary")
@Slf4j
public class SalaryController {
    @Autowired
    private SalaryService salaryService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("ask:salary:list")
    public R list(@RequestParam Map<String, Object> params){
//        log.info("工资params{}",params);
        PageUtils page = salaryService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{salaryId}")
    @RequiresPermissions("ask:salary:info")
    public R info(@PathVariable("salaryId") Long salaryId){
		SalaryEntity salary = salaryService.getById(salaryId);

        return R.ok().put("salary", salary);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("ask:salary:save")
    public R save(@RequestBody SalaryEntity salary){
		salaryService.save(salary);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("ask:salary:update")
    public R update(@RequestBody SalaryEntity salary){
        log.info("salary{}",salary);
		salaryService.updateById(salary);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("ask:salary:delete")
    public R delete(@RequestBody Long[] salaryIds){
		salaryService.removeByIds(Arrays.asList(salaryIds));

        return R.ok();
    }

}
